<%@ page import="java.util.List" %>
<%@ page import="com.xunfang.demo.entity.UserDemo" %><%--
  Created by IntelliJ IDEA.
  User: 星星在唱歌
  Date: 2022/2/17
  Time: 18:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<style>
    table{
        border-collapse: collapse;
        border-color: #000000;
        width: 800px;
    }
</style>
<body>
<%
//    String user = (String) request.getSession().getAttribute("username");
//    if(user==null){
//        response.sendRedirect(request.getContextPath()+"/index.jsp");
//    }
%>
<span>
    欢迎您
    <%=session.getAttribute("username")%>
    <a href="<%=request.getContextPath()%>/DelSessionServlet">登出</a>
</span>
<h1>用户列表</h1>
<table border="1">
    <thead>
        <th>编号</th>
        <th>姓名</th>
        <th>地址</th>
        <th>操作</th>
    </thead>
    <tbody>
        <%
            List<UserDemo> list = (List) request.getAttribute("list");
            for (UserDemo userDemo : list) {
        %>
        <tr>
            <td><%=userDemo.getId()%></td>
            <td><%=userDemo.getUserName()%></td>
            <td><%=userDemo.getAddress()%></td>
            <td><a href="<%=request.getContextPath()%>/del?id=<%=userDemo.getId()%>">删除</a></td>
        </tr>
        <%
            }
        %>
    </tbody>
</table>
<a href="<%=request.getContextPath()%>/index.jsp">返回登录</a>
</body>
</html>
